<template>
  <div class="page">
    <div class="weui-cells">
      <div class="weui-cell">
        <div class="weui-cell__hd">{{result.id}}</div>
      </div>
      <div class="weui-cell">
        <div class="weui-cell__hd txtlist">
          <p><span>顾客姓名：</span>{{result.cusName}}</p>
          <p><span>费用日期：</span>{{result.time}}</p>
          <p><span>订单类型：</span>{{result.status==1?'首单':'非首单'}}</p>
          <p><span>顾客级别：</span>{{result.level}}</p> 
          <p><span>订单金额：</span>{{result.onlineSum}}元</p>
          <p><span>提成比例：</span>{{result.allRatio}}%</p>
          <p><span>提成金额：</span>{{result.allSum}}元</p>
        </div>
      </div>
    </div>
    <div class="weui-cells">
      <div class="weui-cell">
        <div class="weui-cell__hd">到店奖</div>
      </div>
      <div class="weui-cell">
        <div class="weui-cell__hd txtlist" v-if="result.status==1">
          <p><span>顾客姓名：</span>{{result.cusName}}</p>
          <p><span>到店日期：</span>{{result.createTime}}</p>
          <p><span>到店门店：</span>{{result.store}}</p>
          <p><span>提成金额：</span>{{result.allSum}}元</p>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
   import * as appId from "@/utils/util"
  import {getTIme} from "@/utils/util"
  import {toDecimal2} from "@/utils/util"
export default {
  data () {
    return {
      phone:"",
      userId:"",
      result:{},
      id:""
    }
  },
  onLoad(option){
    this.id=option.id;
  },
  onShow(){
    wx.setNavigationBarTitle({
      title: "提成明细"
    })
   this.userInfo =wx.getStorageSync('userInfo')&&JSON.parse(wx.getStorageSync('userInfo'))
   if(this.userInfo){
     this.phone=this.userInfo.mobileNo;
     this.userId=this.userInfo.baseUserId;
     this.getDetail()
   }else{
      wx.showToast({
                    title:'请先登录',
                    icon: 'none',
                    duration: 2000
                  })
   }

  },
  methods: {


    getDetail(){

       this.$http.request({
                method:"post",
                url:"/v1.0/appletLogin/myCommissionDetail",
                body:{
                 "appid":appId.appId,
                 	"phone":this.phone,
                 	"productId":this.id,
                 	"userId":this.userId
                }
      }).then((data)=>{
        if(data.code==0){
          this.result=data.result;
          this.result.time=getTIme(this.result.staTime)
          this.result.createTime=getTIme(this.result.createTime)
          console.log(this.result.commissionAmount/this.result.reorderAmount)
          this.result.bili=toDecimal2(this.result.commissionAmount/this.result.reorderAmount)
        }
      })
    }
  },

  created () {
  }
}
</script>

<style scoped>
.txtlist p{
  font-size: 0.9em;
}
.txtlist p span{
  color: #999;
}
</style>
